package com.hyb.weibo.common.service;

import tk.mybatis.mapper.common.BaseMapper;

import java.util.List;


public abstract class BaseService<T> {

    private BaseMapper<T> mapper;
    protected  void setMapper(BaseMapper<T> mapper){
        this.mapper = mapper;
    }
    protected BaseMapper<T> getMapper(){
       return this.mapper;
    }

    public List<T> findAll() {
        return mapper.selectAll();
    }

    public List<T> find(T t){
       return  mapper.select(t);
    }

    public T findById(Object o) {
        return mapper.selectByPrimaryKey(o);
    }

    public int findCount(T t) {
        return mapper.selectCount(t);
    }

    public T findOne(T t) {
        return mapper.selectOne(t);
    }

    public int delete(T t) {
        return mapper.delete(t);
    }

    public int deleteById(Object o) {
        return mapper.deleteByPrimaryKey(o);
    }

    public int insert(T t) {
        return mapper.insert(t);
    }

    public int insertSelective(T t) {
        return mapper.insertSelective(t);
    }

    public int updateById(T t) {
        return mapper.updateByPrimaryKey(t);
    }

    public int updateByIdSelective(T t) {
        return mapper.updateByPrimaryKeySelective(t);
    }

    public boolean existsWithId(Object o) {
        return mapper.existsWithPrimaryKey(o);
    }

}